
function CatmullRomCams.SV.Save(save_data)

	if not CatmullRomCams.Tracks[player.GetByID(1):UniqueID()] then
		return 
	end
	
	local SaveGameData = {}
	
	for numpad_key, track in pairs(CatmullRomCams.Tracks[player.GetByID(1):UniqueID()]) do
		SaveGameData[numpad_key] = 1
		if false then
			for index, node in ipairs(track) do
				SaveGameData[numpad_key][index] = {Ent = node:EntIndex(), Data = node:RequestSaveData(true)}
			end
		end
	end
	
	return saverestore.WriteTable(SaveGameData, save_data)
end

function CatmullRomCams.SV.Restore(restore_data)

	local SavedGameData = saverestore.ReadTable(restore_data)
	local plyID = player.GetByID(1):UniqueID()
	PrintTable(SavedGameData)
	
	for numpad_key, track in pairs(SavedGameData) do

			if CatmullRomCams.Tracks[plyID] then
				CatmullRomCams.Tracks[plyID][numpad_key] = {}
				
				for index, data in ipairs(track) do
					CatmullRomCams.Tracks[plyID][numpad_key][index] = ents.GetByIndex(node.Ent)
					CatmullRomCams.Tracks[plyID][numpad_key][index]:ApplyEngineSaveData(node.Data, index == 1)
					
					print("Loaded ", CatmullRomCams.Tracks[plyID][numpad_key][index], "'s saverestore data.\nDumping:")
					PrintTable(node.Data)
				end

				numpad.OnDown(player.GetByID(1), numpad_key, "CatmullRomCamera_Toggle", CatmullRomCams.Tracks[plyID][numpad_key][1])
			end

	end
end

saverestore.AddSaveHook("CatmullRomCams_SaveRestore", CatmullRomCams.SV.Save)
saverestore.AddRestoreHook("CatmullRomCams_SaveRestore", CatmullRomCams.SV.Restore)
